package com.computer.cart;

import java.util.HashMap;
import java.util.Map;

import com.computer.product.Computer;

public class Cart {
	private Map<String, CartItem> map = new HashMap<>();
	
	public void addProduct(Computer p) {
		if(map.containsKey(p.getBrand())) {
			CartItem ci = map.get(p.getBrand());
			ci.setCount(ci.getCount() + 1);
			
		}else {
			CartItem ci = new CartItem();
			ci.setP(p);
			ci.setCount(1);
			map.put(p.getBrand(), ci);
		}
	}
	
	public Map getAll() {
		return map;
	}

}
